<html>
<body>

<!--   -->
<!-- Local Scope

A variable declared within a PHP function is local and can only be accessed within that function  -->
<?php
$a = 5; // global scope

function myTest()
{
echo $a; // local scope
} 

myTest();
?>



<!-- Global Scope

Global scope refers to any variable that is defined outside of any function.

Global variables can be accessed from any part of the script that is not inside a function.

To access a global variable from within a function, use the global keyword  -->
<?php
$a = 5;
$b = 10;

function myTest()
{
global $a, $b;
$b = $a + $b;
} 

myTest();
echo $b;
?>


<!--   -->

</body>
</html>